import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const NotFound = () => import('../pages/notFound/NotFound.vue')
const Home = () => import('../pages/home')
const Login = () => import('../pages/login')
const Sort = () => import('../pages/sort')
const ShoppingCart = () => import('../pages/shoppingCart')
const Mine = () => import('../pages/mine')
const CouponPage = () => import('../pages/mine/couponPage.vue')
const Detail = () => import('../pages/detail')
const GoSearch = () => import('../pages/goSearch')

const router = new Router({
    
    // mode: 'hash',
    routes: [
        {
            path: '/',
            redirect: '/login',
            // children: [{
            //     meta: { requireLogin: true },
            //     path: '/home',
            //     component: Home
            // }],

        },
        { path: '/login', component: Login },
        { path: '/home', component: Home },
        { path: '/sort', component: Sort },
        { path: '/shoppingCart', component: ShoppingCart },
        { path: '/mine', component: Mine },
        { path: '/mine/couponpage', component: CouponPage },
        { path: '/detail/:id',name:'detail', component: Detail },
        { path: '/search',name:'search', component: GoSearch },
        { path: '*', component: NotFound }
    ]
})

// export const VueRouterPush = Router.prototype.push
// Router.prototype.push = function push (to) {
//   return VueRouterPush.call(this, to).catch(err => err)
// }

export default router